<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminVillageTable extends Migration
{
    /**
     * Run the migrations.
     *
     * 多对多关联
     * 村《=》管理员表，一个村可以由多个管理员管辖，一个管理员可以管辖多个村
     * @return void
     */
    public function up()
    {
        Schema::create('admin_village', function (Blueprint $table) {
            $table->id();
            $table->foreignId('wxuser_id')->nullable()->constrained()->onDelete('cascade');
            $table->foreignId('village_id')->nullable()->constrained()->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_village');
    }
}
